package com.cpkso.yzx.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.cpkso.yzx.domain.Info;
import com.cpkso.yzx.domain.Msg;
import com.cpkso.yzx.domain.Qq;
import com.cpkso.yzx.dto.MsgQuery;
import com.cpkso.yzx.service.ContactService;

import runze.util.base.BaseAction;
import runze.util.base.Response;

/**
 * @author wrzhxy@qq.com
 * @date 2017年11月10日
 */
@SuppressWarnings("serial")
@Controller
@Scope("prototype")
public class ContactAction extends BaseAction<Object> {
	public String showqq() {
		response = contactService.showqq();
		return SUCCESS;
	}
	public String showinfo() {
		response = contactService.showinfo();
		return SUCCESS;
	}
	public String leaveMsg() {
		long leaveMsg = contactService.leaveMsg(msg);
		if (leaveMsg == 0) response.failure();
		else response.success();
		
		return SUCCESS;
	}
	public String addQq() {
		contactService.addQq(qq);
		return SUCCESS;
	}
	public String delQq() {
		contactService.delQq(qq.getId());;
		return SUCCESS;
	}
	public String modifyQq() {
		contactService.modifyQq(qq);;
		return SUCCESS;
	}
//	public String addInfo() {
//		contactService.addInfo(info);
//		return SUCCESS;
//	}
//	public String delInfo() {
//		contactService.delInfo(info.getId());
//		return SUCCESS;
//	}
	public String modifyInfo() {
		if (info != null) info.setId((long)1);
		else { response.failure(); }
		contactService.modifyInfo(info);
		
		response.success();
		return SUCCESS;
	}
	public String showMsgs() {
		
		response = contactService.showMsgs(msgQuery);
		return SUCCESS;
	}
	public String delMsg() {
		contactService.delMsg(msg.getId());;
		return SUCCESS;
	}
	public String modifyMsg() {
		contactService.modifyMsg(msg);;
		return SUCCESS;
	}
	public String showMsg() {
		response = contactService.showMsg(msg.getId());
		return SUCCESS;
	}
	public String read() {
		contactService.read();
		return SUCCESS;
	}
	
	private MsgQuery msgQuery;
	public MsgQuery getMsgQuery() {
		return msgQuery;
	}
	public void setMsgQuery(MsgQuery msgQuery) {
		this.msgQuery = msgQuery;
	}
	private Qq qq;
	public Qq getQq() {
		return qq;
	}
	public void setQq(Qq qq) {
		this.qq = qq;
	}
	private Info info;
	public Info getInfo() {
		return info;
	}
	public void setInfo(Info info) {
		this.info = info;
	}
	private Msg msg;
	public Msg getMsg() {
		return msg;
	}
	public void setMsg(Msg msg) {
		this.msg = msg;
	}
	private Response response = new Response();
	public Response getResponse() {
		return response;
	}

	@Autowired
	private ContactService contactService;
}
